Cleans up protocol testing, fixes a few bugs