anchor.diff:      , fun setup_server_stop/1
       , [ fun test_start_stop_device/1
         , fun test_add_list_devices/1
  +      , fun test_concurent_stop/1
         ]
       }.
   
  
positive.code: % This can happen when there was device stop requested,
  % however the device has exited meanwhile.
  reply_stop( undefined ) -> ok;
  reply_stop( From ) -> gen_server:reply( From, ok ).
  
  
  handle_poll( _Msg, _DeviceId, State ) ->
  
negative.code:     end.
  
  
  handle_stop_device_request( DeviceId, From, State ) ->
      do_handle_stop_device_request(
          orddict:find( DeviceId, State#state.devices ),
          From, State
       ).
  
  do_handle_stop_device_request( { ok, Device }, From, State ) ->
      ok = lurch_device:stop( Device#device.id ),
      NewDevice = Device#device{
          state = stopping,
          stopped_by = [ From | Device#device.stopped_by ]
      },
      NewDevices = orddict:store( Device#device.id, NewDevice, State#state.devices ),
      NewState = State#state{ devices = NewDevices },
      { noreply, NewState };
  
  do_handle_stop_device_request( error, _From, State ) ->
      { reply, { error, no_such_device }, State }.
  
  
  %% ===================================================================
  %% Tests
  