Make tests use modular couch storage
manage.js mostly modularised and fixed in many ways