Tests added and refactored