Fixes for binary protocol implementation.
Gateway test application.