serf: Add serf_set_type() to change serf type and update global state consistently