Moved message handler creation into an own function
Attempt to make createAsyncFunction() as bit simpler