Backport the test functions from newer Twisted versions for compatibility.