Adding some missing protocol-related functions.
Whitespace changes.
Adding some test cases.