Detail modules and tests names in the logging callbacks

Fixes #685 (partially for the regressions on `test/setTimeout.html` and `test/stack.html`)
Fixes #677

Ref: #662 
Ref: #674
Move this definition up to the var declaration. Modifications to `testEnvironment` apply to any reference, and that code will eventually disappear anyway.