PLAT-345 fix $textMessage omission

The $textMessage variable was not being passed into the scope of the
anonymous function being called via the GlobalStateWrapper. Added it to
the scope and added a test to make sure it's being passed through.

/cc @grunny