make string check in template tag py3 compatible
use range instead of xrange

xrange is not present in python 3
make tests more python 3 compatible