Replace instanceof template variable with variable segment
Add test for instanceof template