write test in test database
refactors test - always clear test db after running test.
refactors tests