Modified api so that it can use a test database for tests