Implement a disjoint-set forest and tests