added tests and refactored models