Fix the context when iterating through dictionaries

- Use item values instead of keys as local context
- Use `items` for iterating through dictionaries and `enumerate` when iterating through other iterables