several bug fixes

This is almost everything needed to be able to run the SoftHSM test suite over pkcs11-proxy. I'm just pondering one final issue.