fixed indexing on trimming, finalized tests