fix(db): add default argument for db callback
#SOCRFW-129
style(mediator): fix code style
refactor(mediator): rewrite loops in coffeescript fashion
refactor(mediator): finish refactoring loops