Add unit tests

Since we're writing JSON now, you should use 'utf8' still.