Protocol: added tests for encode