Add sort tests

fix function(changes,n): n was not always correct.