Make lookup order consistent with f3f9e257.
Speed up looking from a PHP scope into an outer Python scope.

On a small benchmark that does this repeatedly, this leads to a roughly 2.5x
speedup.
Test first-class functions and closures more completely.