Add canonical writer, more tests.