MULE-6990: OOM exception using foreach

_ Fixing test
(cherry picked from commit 77941e3)