clean code up and fix unit tests
update crypt code