added db implementation. some more tests.