refactor database.py to use csv importer, update tests