This prevents side effects in tests by properly cleaning up even with expected exceptions. Signed-off-by: Vincent Petry <vincent@nextcloud.com>