 
     test 'single tap', (done) ->
         element = $('.a').get(0)
-        singleCount = 0; doubleCount = 0
-
-        DOMEvents.addListener element, 'singletap', (event) -> singleCount++
-        DOMEvents.addListener element, 'doubletap', (event) -> doubleCount++
-
-        down(element, 10, 10)
-        up(element)
-
-        setTimeout ->
-            assert.equal singleCount, 1
-            assert.equal doubleCount, 0
+        counterSingle = new Number.Counter
+        counterDouble = new Number.Counter
+
+        DOMEvents.addListener element, 'singletap', counterSingle.step
+        DOMEvents.addListener element, 'doubletap', counterDouble.step
+
+        down(element, 10, 10)
+        up(element)
+
+        setTimeout ->
+            assert.equal counterSingle, 1
+            assert.equal counterDouble, 0
             DOMEvents.removeListener element, '*'
             done()
         , 300
 
     test 'double tap', (done) ->
         element = $('.a').get(0)
-        singleCount = 0; doubleCount = 0
-
-        DOMEvents.addListener element, 'singletap', (event) -> singleCount++
-        DOMEvents.addListener element, 'doubletap', (event) -> doubleCount++
+        counterSingle = new Number.Counter
+        counterDouble = new Number.Counter
+
+        DOMEvents.addListener element, 'singletap', counterSingle.step
+        DOMEvents.addListener element, 'doubletap', counterDouble.step
 
         down(element, 10, 10)
         up(element)


    test 'long tap', (done) ->
        element = $('.a').get(0)
        count = 0

        DOMEvents.addListener element, 'longtap', -> count++
        down(element, 10, 10)

        setTimeout ->
            up(element)
            assert.equal count, 1
            DOMEvents.removeListener element, '*'
            done()
        , 900

    test 'a move cancels long tap', (done) ->
        element = $('.a').get(0)
        count = 0

        DOMEvents.addListener element, 'longtap', -> count++
        down(element, 10, 10)

        setTimeout ->
            move(element, 50, 10)
            setTimeout ->
                up(element)
                assert.equal count, 0
                DOMEvents.removeListener element, '*'
                done()
            , 450


DOMEvents = Rye.require('DOMEvents')
touchEvents = Rye.require('TouchEvents')

makeElement = (tagName, html, attrs) ->
    el = document.createElement(tagName)
