Started refactoring DB interface and adding unit tests