Finish adding tests for database operations

Add a test to ensure that write_pull_requests_to_database is working
properly and refactor that method slightly to make it easier to
test.