Wrap tags correctly when passed as a function.

This solves #737, and seems to work with other demos. Is there a test suite somewhere?