BFS and tests