Adding unit test for ComponentTree, also fixing some bugs on component tree algorithm detected with the unit test