Refactor tpl codes

- Use indirect function instead of the same code copies
- Fix missing arguments of some test codes