added nil check to tests for breadth first algorithm.