Fix template blocks and write tests for them