added coverage for the db and fixed a bug