wrote unit tests & fixed bugs