tests and minor changes to variable scopes