Added unit test, readme, fixed bugs