Calculates remainingLength based on data

- Instead of remainingLength property, calculates the
  remainingLength field in the fixed header based on
  the variable header and payload
- Adds variable header and payload data to the message