Restructured the implementation of assert_dom_equal and assert_dom_not_equal.