if EC_KEY_check_key fails consume errors off stack (+ add test)

fixes #1389