Add unit tests for and document dbworker

Also remove a few unused imports