added some tests, refactored model