Added factories for tests
More correct model->json export, test fixes.
Added model factories for tests