Added unit tests, fixed deepest_first parameter