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)