cleaned up SortScan and added tests

also added scoping to SortScan in units_access/helper.cpp