fixed bugs and added unit test