Add unit tests for the `generateYuiModuleForTemplates` function and fix the broken code and documentation the tests uncovered (yay tests!).