Fixed bug in the unit tests

A bug was introduced into these unit tests where a reference to a stack
variable was added to a lambda but that lambda was not used from within
the scope of the declaring function. This problem was only seen when
the tests were compiled non-optimized.