test for preserving variables in nested scopes