If I were doing what you are looking to do, I would create 3 templates instead of 2. I would assign a variable to the test footer and test header like:
PHP Code:
eval('$testheader = "' . fetch_template('test_header') . '";');
eval('$testfooter = "' . fetch_template('test_footer') . '";');
and then I would create a third template as:
PHP Code:
eval('print_output("' . fetch_template('new_template') . '");');
Within the new template, just add $testheader and $testfooter whereever you want them to appear. Between the 2 you can add whatever you like without having to echo anything.