     url = null
 
     setupTestData = Promise.coroutine (geocaches) ->
-        g = geocache db
+        geocaches = JSON.parse JSON.stringify geocaches
+        g = geocacheService db
         yield g.deleteAll()
         for geocache in geocaches
             yield g.upsert geocache

            expect(response.body).to.include.members ['GC100']

        it 'should filter by type id using "typeIds"', Promise.coroutine ->
            yield setupDatabase [
                gc '100',
                    CacheType:
                        GeocacheTypeId: 5
                gc '101',
                    CacheType:
                        GeocacheTypeId: 6
                gc '102',
                    CacheType:
                        GeocacheTypeId: 7
            ]
            response = yield request
                .get "#{url}/gcs"
                .query typeIds: [5, 7]
                .set 'Accept', 'application/json'
            expect(response.type).to.equal 'application/json'
            expect(response.body.length).to.equal 2
            expect(response.body).to.include.members ['GC100', 'GC102']

        it 'should filter disabled/archived geocaches using "excludeDisabled"', Promise.coroutine ->
            yield setupDatabase [
                gc '100',
                    Archived: false
                    Available: false
                gc '101',
                    Archived: false
                    Available: true
                gc '102',
                    Archived: true
                    Available: false
                gc '103',

    gc = (id, options) ->
        defaults =
            Code: "GC#{id}"
            Name: 'geocache name'
            Latitude: 10
            Longitude: 20
            Terrain: 1
            Difficulty: 1
            Archived: false
            Available: true
            CacheType: GeocacheTypeId: 2
            ContainerType: ContainerTypeName: 'Micro'
            UTCPlaceDate: "/Date(#{new Date().getTime()}-0000)/"
            EncodedHints: 'some hints'
        merge = (a, b) ->
            return a unless b?
            for k, v of b
