#3 refactored tests and fixed bugs