I was looking at your code and found one probable issue.
Code:
// pre-cache templates used by all actions
$globaltemplates = array(
// change the lines below to the list of actual templates used in the script
'test_mytesttemplate1',
'test_mytesttemplate22',
);
If you look at $globaltemplates = array( your closing parenthesis is not there until after the test_mytetstemplate22. Try fixing that and see if it works.