diff --git a/tests/src/Unit/DomHelperTraitTest.php b/tests/src/Unit/DomHelperTraitTest.php
index 17b75e3..c45ef6a 100644
--- a/tests/src/Unit/DomHelperTraitTest.php
+++ b/tests/src/Unit/DomHelperTraitTest.php
@@ -72,6 +72,19 @@ class DomHelperTraitTest extends UnitTestCase {
     // Test replacing again with a non-empty value.
     $this->replaceNodeContent($this->node, '<div></div>');
     $this->assertEquals(Html::serialize($this->document), '<outer><div></div></outer>');
+    // Test replacing again with a value without root element.
+    $two_nodes = $this->replaceNodeContent($this->node, '<p>first</p><p>second</p>');
+    $this->assertEquals(Html::serialize($this->document), '<outer><p>first</p><p>second</p></outer>');
+    $this->assertEquals(count($two_nodes), 2);
+    // Test replacing again with a non-empty value.
+    $new_nodes = $this->replaceNodeContent($this->node, '<p>third</p>');
+    $this->assertEquals(Html::serialize($this->document), '<outer><p>first</p><p>third</p></outer>');
+    $this->assertEquals(count($new_nodes), 1);
+    // Test replacing of returned DOMNode objects.
+    $this->node = $two_nodes[0];
+    $new_nodes = $this->replaceNodeContent($this->node, 'Second <!-- comment --> ');
+    $this->assertEquals(Html::serialize($this->document), '<outer>Second <!-- comment --> <p>third</p></outer>');
+    $this->assertEquals(count($new_nodes), 3);
   }
 
   /**
