[#725] Fixes optimization logic

* We want to only calculate the signature if `allowUnsignedData` is
  false
* We need to check if we have a .sig to compare to and, if we have
  actual data to calculate the signature on. If one of those is
  missing we throw an Exception.