Simplify template logic. * Add function to generate test inputs. * Refactor template structure. Change-Id: I1913a75b6f7ac478d77722740970af26400585e4