Tests
Factored out modelfactory, added test helpers and tests for views.