Replace explode_hash with a simpler and clearer implementation

Also rename PathToHash module to KeyPathToHash and add tests.