Added user tests and refactoring