Yeah, it's not a great idea.  The options are mainly this and having the unit test provide a separate module that gets loaded into the main thread context.  So test_mail_html.js would have its buddy test_mail_html-mainthread.js that it could cause to be loaded and which could help it out.  That seemed like it would be a hassle and potentially even more confusing to follow the relationship between the two files.  I am definitely open to better solutions.  I figured since WebDriver/selenium and even our test frameworks do it, people may not be too upset about it.