Unwind resources that were defined more than once

This fixes a bug where a resource defined more than once would get removed from the `run_context.resources` array once per definition, but the indexes in `run_context.resources_by_name` would only get offset by 1.

The result of the bug was similar to #16, where lookup would return the wrong resources after an unwind.