Add unit tests

Use `Buffer` instead of `Uint8Array` everywhere in this file.