Detect resolve loops
Template should expand
Detect cycles in expand
Add cycle detection tests