Added factorial test and fixed a bug in the JS library