- fixed bugs and added test cases