Added Unit-Tests for db.py and some more logging/exceptions