fix test suites

To test:
````
for i in test/unit/*; do ./node_modules/.bin/jaribu $i; done
for i in test/unit/baseclient/*; do ./node_modules/.bin/jaribu $i; done
````
Please assign all util functions to local variables on top of all other function definitions. That way it's clear what the dependencies are and we can later switch the variable assignments to using proper ES6 imports.