Added tests and fixed several bugs
README.md update