Contacts: Various fixes found when adding unit tests. Unit tests FTW \o/
Contacts: Unit tests for Database backend.