Fixed encryption/decryption and wrote tests