Refactoring spec for db