Bug fixes to Contact Database and testing improvements