not finished!Totally rewritten db tests,

and refactored db.js,