Fixes and tests for for_each()
Fixed docstring