Fixed issue with variable hoisting causing false negative in tests