update tests to work with ws@0.6
Add a bunch of tests on private functions.

Also add test environment exposure of privates
to simplify testing