Added DatabaseManager and refactored all methods to take callbacks.

Tests fail when not using main thread.