Fix handler state change in cowboy_rest