Testing algorythm for template generator.