Fixed test database bug | refactored tests