Added some new features

Added a couple of features: factory method, chaining, ability to set a base path, did a little bit of refactoring, and added unit tests. Hope you like :).