Added database code and unit tests for the database code