Refactor User class and add tests