indexCopy unit test and less allocations