Fix bug of header encoding

* The previous commits could not pass the tests was because of the
  mistake header shifting, witch means the tests' explanation and the
  protocol's explanation of the specification were not the same!