refactoring the template and key testing logic