fix blatently wrong code in path_to_top_of_module_tree function
enhance unit test to catch missed bug
Merge pull request #1054 from boegel/fix_filtering_deps_to_top_of_module_tree

fix blatently wrong code in path_to_top_of_module_tree function