Merge pull request #335 from jugglinmike/add-regression-test

Add regression test for `children` filtering
Fix `replaceWith` method

Ensure that node structures are updated accordingly and update the tests
to verify the expected behavior of the method.