Add tests for PR 13094.

The bug itself was fixed already when ordinary
type variable scoping was fixed.

Closes PR 13094