move function definitions outside of a function

Hidden functions are difficult to test and should be avoided.
Merge pull request #10 from kanzure/cleanup-hidden-functions

Move hidden functions into the main scope