Try to fix a test failure which happens for some people
Fix undefined behavior issue
send back an error if there's an encryption failure