Add `build_sanitized_path` to remove code duplication
Convert and use old `sanitize_path` tests