About Flowable Event trigger order

When I create a process instance, I will receive a task create event at first, then I will receive a process instance created event.Why?

Can you share a unit tests / example code? What kind of events are you capturing?