Refactor and new tree test added