SERVER-14268: Improve server message parsing

(cherry picked from commit dac9ac4a46348a67296b8b3ff11c58e522bd1b0b)