refactor module

 * simpler less error-prone code
 * ability to not console.log on error
 * add tests
 * documentation moved to readme for better accessibility