refactored database test logic.