Fix broken unit tests in generated files

Made some changes to the templates so that the unit tests run
directly out-of-the-box.