Remove global variables

Fix to prevent global leaks errors when I run mocha test on my project.

Thanks to accept this PR.