(#22784) Remove the foreach functions

The each function should be used instead.
(#22784) Update tests that indirectly depended on foreach function.

Tests updated to use the each function.
Merge pull request #1972 from hlindberg/issues/issue-22784-remove-foreach

Issues/issue 22784 remove foreach
Merge branch 'master' of https://github.com/puppetlabs/puppet