You're right. I will change it to use substr instead of preg_match.

I've added this test so we can be sure that we will avoid doing file_exists on template file. As this method is only used for template, i'll remove it.