Bug 445410 - [Occurrences] Does not mark occurrence that happens in a nested scope BEFORE the declaration
Also improves debug output when tests fail. Fix removes the need for a globals array.