Resolves #1 by removing global module dependency

Also adds unit tests
Merge pull request #2 from achingbrain/master

Resolves #1 by removing global module dependency