unit test for BFS