Add test for ensureCapacity