make db more testable and test it