Fix/test pre key generation
Move crypto things to js/crypto.js