added unit tests for database delete and code refactor