Added tests for the User model and fixed some bugs found