Extract config key deletion to a method

Avoid the cryptic `delete_if`