Modify a sorted array with some elements duplicated, and compact the array by removing the duplicates, returning the new length of the array.  Uses unit tests for validation.