What behavior check is this code?
It looks non-existing key deleton never affect, so never raise exception, never delete existing key.
Do you have to check size of key_manager?