Add databaseLock
Fix test query
Tweak databaseErase and close the dbQueue when locking
More unit tests