Added server response check (throws an exception if the server sends an
unexpected message)