anchor.diff:  register_rm_event_handler() ->
     EventHandler = fun(Event) ->
       ?info("RmEvent Handler"),
  -    UserDn = proplists:get_value(user_dn, Event),
  -    FuseId = proplists:get_value(fuse_id, Event),
  -    case user_logic:quota_exceeded({dn, UserDn}) of
  -      false -> request_dispatcher:send_to_fuse(FuseId, #atom{value = "write_enabled"}, "communication_protocol");
  -      _ -> ok
  +    QuotaExceededFn = fun() ->
  +        UserDn = proplists:get_value(user_dn, Event),
  +        FuseId = proplists:get_value(fuse_id, Event),
  +        case user_logic:quota_exceeded({dn, UserDn}) of
  +          false ->
  +            request_dispatcher:send_to_fuse(FuseId, #atom{value = "write_enabled"}, "communication_protocol"),
  +            false;
  +          _ ->
  +            true
  +        end
  +    end,
  +
  +    Exceeded = QuotaExceededFn(),
  +
  +    %% if quota is exceeded check quota one more time after 5s - in meanwhile db view might get reloaded
  +    case Exceeded of
  +      true ->
  +        spawn(fun() ->
  +          receive
  +            _ -> ok
  +          after 5000 ->
  +            QuotaExceededFn()
  +          end
  +        end);
  +      _ ->
  +        ok
       end
     end,
   
  
positive.code:   {ok, UserDoc} = user_logic:get_user({login, UserLogin}),
    user_logic:update_quota(UserDoc, #quota{size = NewQuotaInBytes}).
  
  %% For test purposes
  prepare() ->
    register_write_event_handler(1),
    register_quota_exceeded_handler(),
    register_rm_event_handler(),
    change_quota("plgmsitko", 100).
negative.code: 
  %% functions for manual tests
  -export([register_mkdir_handler/0, register_mkdir_handler_aggregation/1, register_write_event_handler/1, register_quota_exceeded_handler/0,
           send_mkdir_event/0, delete_file/1, change_quota/2, register_rm_event_handler/0, prepare/2, register_for_stats/1]).
  
  -ifdef(TEST).
  -compile([export_all]).
  