     door = create_door door_group: door_group
     member = create_member company: company, door_group: door_group
     rfid_token = create_rfid_token member: member
-    assert RfidToken.access_permitted?("abcd1234", door.id)
+    assert RfidToken.access_permitted?(rfid_token.identifier, door.id)
   end
 
   test "checking that the door should not be allowed to open if the token is inactive" do
     company = create_company
     member = create_member company: company
+    door_group = create_door_group
+    door = create_door door_group: door_group
     rfid_token = create_rfid_token member: member, active: false
-    refute RfidToken.access_permitted?("abcd1234")
+    refute RfidToken.access_permitted?(rfid_token.identifier, door.id)
   end
 
   test "the door should not be allowed to open if the member is inactive" do
     company = create_company
     member = create_member company: company, active: false
+    door_group = create_door_group
+    door = create_door door_group: door_group
     rfid_token = create_rfid_token member: member
-    refute RfidToken.access_permitted?("abcd1234")
+    refute RfidToken.access_permitted?(rfid_token.identifier, door.id)
   end
 
   test "the door should not be allowed to open if the company departed" do
     {:ok, departure} = Ecto.DateTime.cast("2015-04-30 00:00:00")
     company = create_company departure_date: departure
     member = create_member company: company
+    door_group = create_door_group
+    door = create_door door_group: door_group
     rfid_token = create_rfid_token member: member
-    refute RfidToken.access_permitted?("abcd1234")
+    refute RfidToken.access_permitted?(rfid_token.identifier, door.id)
   end
 
   test "the door should not be allowed to open if the token is not enrolled" do
-    refute RfidToken.access_permitted?("abcd1234")
+    door_group = create_door_group
+    door = create_door door_group: door_group
+    refute RfidToken.access_permitted?("does_not_exist", door.id)
   end
 end

    {:ok, door} = Repo.insert(changeset)

    if params[:door_group] do
      changeset = DoorGroupDoor.changeset(%DoorGroupDoor{}, door_id: door.id, door_group_id: params.door_group.id)
      Repo.insert(changeset)
    end


    {:ok, member} = Repo.insert(changeset)

    if params[:door_group] do
      changeset = DoorGroupMember.changeset(%DoorGroupMember{}, %{member_id: member.id, door_group_id: params.door_group.id})
      Repo.insert(changeset)
    end

