Fix untested contract generation code.

Closes PR 13449.