def get_response(link, phase, params, fail_msg):
    """Get response and check if the state is correct."""
    response = next(link.receive())
    response = response.split(',')

    if len(response) != params or response[0] != phase:
        raise RuntimeError(fail_msg)
    return response