The main culprit seems to be an ITVF that was of the form:
WITH Results1 AS (SELECT SortOrder = ROW_NUMBER() OVER(ORDER BY X, Y, Z), TestTitle, TestResult FROM sometests)
, Results2 AS (SELECT SortOrder = (SELECT MAX(SortOrder) FROM Results1) + ROW_NUMBER() OVER(ORDER BY A, B, C), TestTitle, TestResult FROM someothertests)
, Results3 AS (SELECT SortOrder = (SELECT MAX(SortOrder) FROM Results2) + ROW_NUMBER() OVER(ORDER BY Q, R), TestTitle, TestResult FROM stillsomeothertests)
SELECT * FROM Results1