Adds tests for DocumentType enum, and makes a few changes that should not change behaviour.

Also a few notes for changes to make in the future - too risky to do just before a release.