cleaned up code and added tests plus better explanation in the README.md