Fix race in error handling test
Make ref an optional dependency

The ref module adds a compile step even when using the pure-JavaScript client.
This makes the installation optional so if the install fails due to not having
a compiler around you can still use the JavaScript client.

closes #398