Unit tests and fixes for refactored legacy db code
Merge remote-tracking branch 'origin/release' into release