Added tests and refactored traversal utils