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)
Yes, I just converted it to count() (haven't committed it yet). count(*) is the right choice because it takes care of some corner case. I will commit it soon, I'm doing some testing.