Fix stack trace not captured when throwing error

The stack trace was not being captured for the NetConnectNotAllowedError. I also took the opportunity to add tests for the Error instance.