Various fixes and features

As discussed on engine_pkcs11 mailing list, I'm offering my patch set for merging into engine_pkcs11 repository. See http://thread.gmane.org/gmane.comp.encryption.opensc.devel/14973 for more details.