Fix on nested templates with unit test