fixed bug in encryption method as well as added some test code