Add some more tests
Fix bugs in encryption