refactor cryptoservice, add unittest for promise