Correct implementation of union, intersect and diff, add tests