Clean up test code, add protocol test