Add tests for SortEncoder.
Fix SortEncoder for None value.
Fix DocumentError.__init__.