encoder.js :: implement encodeRef() and test