Improve how we handle duplicate entry exceptions in the unit tests.

This makes it so we don't have to handle different exceptions for postgres,
sqlite, etc.

The test suite is now back at 100% for me again.