Improve next_event to use better primitives
Test API status code