Rewrite tests more cleanly; add Sort for ordered types; gofmt output