Adjustments to the collating-sequence refactoring to facilitate full-coverage testing and to fix some minor issues found by TH3. FossilOrigin-Name: cdbfa664839a409589ec7cebfc9111235d2f3b38