Fixed shell test errors for conditions with -z, and addressed more bugs with logging.