add license and move file to lib
made compatible with nodejs, fix global leaks
add test cases