       canvas.once "begingroup", (group) ->
         groups.push group
       canvas.once "data", (canvas) ->
-        chai.expect(canvas).to.be.an 'object'
         chai.expect(groups).to.have.length 1
         chai.expect(groups[0]).to.equal id
         done()
-      id = getCanvasWithImage input, (canvas) ->
+      id = testutils.getCanvasWithImage input, (canvas) ->
         ins.beginGroup id
         ins.send canvas
         ins.endGroup()

      input = '1x1.gif'
      id = null
      colors.once "data", (colors) ->
        chai.expect(colors).to.be.an 'array'
        chai.expect(colors).to.have.length 0
        done()
      id = getCanvasWithImage input, (canvas) ->
        ins.send canvas
  describe 'when given not an image', ->
    it 'should return an error', (done) ->
      error.on "data", (err) ->
        chai.expect(err).to.be.an 'object'
        done()
      ins.send ''
  describe 'when given null', ->
    it 'should return an error', (done) ->
      error.on "data", (err) ->
        chai.expect(err).to.be.an 'object'
        done()
      ins.send null

      colors.once "begingroup", (group) ->
        groups.push group
      colors.once "data", (colors) ->
        chai.expect(colors).to.have.length expected.length
        chai.expect(colors[0]).to.have.length 3
        chai.expect(colors).to.deep.equal expected
        chai.expect(groups).to.have.length 1
        chai.expect(groups[0]).to.equal id
        done()
      id = testutils.getCanvasWithImageNoShift input, (canvas) ->
        ins.beginGroup id
        ins.send canvas
        ins.endGroup()
