fix a bug in variadic template code gen
add the template tests