fix(dom-tree) clean up the tree parser

make sure we build the dom tree correctly and add unit tests