Use more appropriate exception class when checking for collisions.

Make some test assertions more specific.