improved functionality and refactored tests