python 2.6 doesn't have functools.cmp_to_key
Clean up the exception assertions.