Fix assignment of IDs to multiple relations when one of them is empty an...

...d add test for it (and in general for ID assignment)
Great. Make sure to run `make test` on a GP machine since the GP test is currently still not automatically covered by Travis or Jenkins. I just tested this version and it passed all tests. The Jenkins test will be fixed soon with Jaeho's help.