Refactored code structure. Added test cases for crypto.