small refactoring and clean ups.
Removed obsolete code and put deleteDatabase at the end of unit testing.