Fixed incorrect replacement of constants in template definition.

Fixed handling of constant lists.

Fixed test case.