             atom.packages.activatePackage("package-with-keymaps-manifest")
 
           runs ->
-            expect(atom.keymaps.findKeyBindings(keystrokes: 'ctrl-z', target: element1[0])).toHaveLength 0
+            expect(atom.keymaps.findKeyBindings(keystrokes: 'ctrl-z', target: element1)).toHaveLength 0
 
       describe "when the package's keymaps are disabled and re-enabled after it is activated", ->
         it "removes and re-adds the keymaps", ->
-          element1 = $$ -> @div class: 'test-1'
+          element1 = createTestElement('test-1')
           atom.packages.observePackagesWithKeymapsDisabled()
 
           waitsForPromise ->


      describe "when the metadata does not contain a 'menus' manifest", ->
        it "loads all the .cson/.json files in the menus directory", ->
          element = ($$ -> @div class: 'test-1')[0]

          expect(atom.contextMenu.templateForElement(element)).toEqual []



          runs ->
            atom.config.set("core.packagesWithKeymapsDisabled", ['package-with-keymaps-manifest'])
            expect(atom.keymaps.findKeyBindings(keystrokes: 'ctrl-z', target: element1)).toHaveLength 0

            atom.config.set("core.packagesWithKeymapsDisabled", [])
            expect(atom.keymaps.findKeyBindings(keystrokes: 'ctrl-z', target: element1)[0].command).toBe 'keymap-1'

    describe "menu loading", ->
      beforeEach ->
