Fixed function dfs. added some tests
Some fixes