More unit tests, and fixes to SortedCollection.