Tests and fixes for Atd_sort. Good to go.