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)
Ok, this is a TODO for later.