Improve latex codec test coverage.

Some bugs fixed as well.