refactoring into a distinct binary and library

I put everything in `lib`, and did some refactoring, mainly to remove every `console.log`.
Instead, a callback receives error, or status code from the response.

I also modified the readme, and added a few tests.