Add tests for bug#1516

SORT/compare ignores the typespec of its function argument.
Add test for bug#1764
Formatting