Updated readme
Made refactoring. Added some tests.