Tests for database service added.
Database service refactored.