Dynamically export helpers

I recently tried to write uninstall script for one of my package and I bumped into same issue reported in #230. I found @zippy1981's PR #278 but it had conflict, so this is just a rebase of his work on latest master.

Test result:
Passed: 317 Failed: 0