PY-6637 Add test cases on detection of nonlocal references inside escalated function