Fixed a collision handling issue in IdMapper

where encoded values where compared before clearing an internal collision
flag on each value. Better testing was added around collision handling to
assert correct behaviour there as well.