Call dlclose() only when having a valid handle.

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
fixed PUK handling

Note that
`SC_PKCS15_PIN_AUTH_TYPE_PIN` is used for `sc_pkcs15_auth_info_t.auth_type`
`SC_PKCS15_TYPE_AUTH_PIN`     is used for `sc_pkcs15_object_t.type`
When setting pointers to a template, ensure they do not get out of scope prior of being used.

This was causing issues when using pkcs11-tool with opencryptoki:
https://bugzilla.redhat.com/show_bug.cgi?id=1062307

Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>