fixed handling of variables passed to template tags

- wrote tests for that
- refactored tests to reduce copypaste