Test for unions and intersections, and bugfixes