Error handling and testing of encryption