diff --git a/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module b/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module
index 1fdbd6d863ae321804c8d98ff28f940e1b0c84b9..3fe1616e7b3583442e7bcf67e5ed83a174d9e323 100644
--- a/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module
+++ b/core/modules/comment/tests/modules/comment_empty_title_test/comment_empty_title_test.module
@@ -9,6 +9,6 @@
 /**
  * Implements hook_preprocess_comment().
  */
-function comment_empty_titles_test_preprocess_comment(&$variables) {
+function comment_empty_title_test_preprocess_comment(&$variables) {
   $variables['title'] = '';
 }
diff --git a/core/modules/comment/tests/src/Functional/CommentTitleTest.php b/core/modules/comment/tests/src/Functional/CommentTitleTest.php
index 8e63f8586bccaa2ab3c8d94d31ee0b2b203b6fcc..b94fd277bc02ce4d6d16042a740a4641b30df006 100644
--- a/core/modules/comment/tests/src/Functional/CommentTitleTest.php
+++ b/core/modules/comment/tests/src/Functional/CommentTitleTest.php
@@ -19,7 +19,19 @@ class CommentTitleTest extends CommentTestBase {
    * Tests markup for comments with empty titles.
    */
   public function testCommentEmptyTitles() {
-    // Installs module that sets comments to an empty string.
+    // Create a node.
+    $this->drupalLogin($this->webUser);
+    $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
+
+    // Post comment #1 and verify that h3 is rendered.
+    $subject_text = "Test subject";
+    $comment_text = "Test comment";
+    $this->postComment($this->node, $comment_text, $subject_text, TRUE);
+    // Tests that markup is generated for the comment title.
+    $regex_h3 = '|<h3[^>]*>.*?</h3>|';
+    $this->assertSession()->responseMatches($regex_h3);
+
+    // Installs module that sets comment title to an empty string.
     \Drupal::service('module_installer')->install(['comment_empty_title_test']);
 
     // Set comments to have a subject with preview disabled.
@@ -27,11 +39,10 @@ public function testCommentEmptyTitles() {
     $this->setCommentForm(TRUE);
     $this->setCommentSubject(TRUE);
 
-    // Create a node.
-    $this->drupalLogin($this->webUser);
+    // Create a new node.
     $this->node = $this->drupalCreateNode(['type' => 'article', 'promote' => 1, 'uid' => $this->webUser->id()]);
 
-    // Post comment #1 and verify that h3's are not rendered.
+    // Post another comment and verify that h3 is not rendered.
     $subject_text = $this->randomMachineName();
     $comment_text = $this->randomMachineName();
     $comment = $this->postComment($this->node, $comment_text, $subject_text, TRUE);
@@ -47,8 +58,9 @@ public function testCommentEmptyTitles() {
     $regex .= '/s';
     // Verify that the comment is created successfully.
     $this->assertSession()->responseMatches($regex);
-    // Tests that markup is not generated for the comment without header.
-    $this->assertSession()->responseNotMatches('|<h3[^>]*></h3>|');
+    // Tests that markup is not generated for the comment title.
+    $this->assertSession()->responseNotMatches($regex_h3);
+    $this->assertSession()->pageTextNotContains($subject_text);
   }
 
   /**