Do not remove items from array being iterated on

This fixes a bug in the clear() method. All tests passes.
new build: all tests passing