fix minification dependency issue and create a module

This is essentially same as #3 and #6 together. I merged them so that I can use. I also updated the tests to make them happy.
This should also fix #5.