code and test for insertion sort