Fix variables scope in test