Refactor it in a separate function so it's more self contained and easier to test.
Refactor it in a separate function so it's more self contained and
easier to test.

StackStorm/st2,Plexxi/st2,nzlosh/st2,nzlosh/st2,nzlosh/st2,StackStorm/st2,Plexxi/st2,Plexxi/st2,StackStorm/st2,Plexxi/st2,nzlosh/st2,StackStorm/st2