Extract normalize_token function in lib folder