some refactoring and some tests for the User