Refactor db tests