Reorganize returns last to satisfy coverage.

Using Istanbul for coverage. It is unhappy with the return of a hoisted
function. It must put a counter in front of the function declaration,
one that doesn't get called because of the early return. I moved the
return statements at the end of factory and cadence functions.