Running tests wiped out the main DB

Fixed bug which wiped out the main DB after running the tests.