Rewriting replace SHA1 code and adding tests