adding format_protocol function and spec tests