new implementation for union, following discussion with Barend;
updated unit test for union a bit;