lib/misc.js: added unit tests for new the functions