Tests and db reset refactoring