Cleaned up check for bad -errorstack; added test case