final touches and refactored tests