complete tests; works on browsers & node.js; also some minor bugfixes