sc-hsm: Improve error detection and reporting in sc-hsm-tool

This patch includes #261 which therefore becomes obsolete.