Fix the unique keys
Add tests and error handling for user registration