Updated unload to be more forgiving about the state of the PKCS11 module

Fixed issue with determining flags for dynamic linking