Moving database logic to McmRepository, and writing tests for extensions.