Moved the union find data structure into separate file. Added test.