refactor tests, add couchdb mock