The listeners would also be attached to the mock document, as line 59 (https://github.com/coderaiser/jemul8/blob/f33826bd6f0057c9ba0141ede64fddacba263b8b/tests/bdd/unit/js/plugins/std.keyboardTest.js#L59) would pass the mock document through to the plugin as util.global.document. Lines 63->83 are there to enable passing in a mock version of the "js/util" dependency for exactly this purpose. :)