Fixed minor bug; added tests; refactoring