Add tests for fromBuffer and toBuffer.
Fix typo in toBuffer().