Ported the code for TestCustomSort and TestSimpleGroupByFacetHandler (although the latter is commented because it won't compile).