add test function, and a function for connected components