Fix up tests, and unique constraints