Implement creation of huffman encoding table.

Also change huffman encoder/decoder to use `new` instead of a factory function,
and implement a few basic tests.