Updated tests and added imports/exceptions

This commit updates the unit tests for the new encryption routine. It
also adds some missing imports and exception declarations.