Fixed bug in switching to lexical environment

There was a bug where the tracing interpreter did not always switch to the environment of the correct closure when executing a trace.