cleaned up traversal code, initial unittest