Make counter (i) non global

This was causing mocha tests to fail due to globals detection