Tests and code for expect->errorCode and expect->errorMsg