(bit ugly I have to say, as we are essentially partially testing "crypto" module here, probably should be instead replaced by a version that mocks crypto module and checks, if the called functions match the expectations)