added type specs for functions in hash module, added test coverage, rearranged and refactored a little bit