Fix error reponses in key handler