refactoring
added some tests
more tests
use inmemory db for all tests
Merge branch 'mitja'