Update tests. Postpone new and deleted objects until transaction commit. Make db-thread more robust and fix restarting it.