Formatted and refactored
Fixed tests and added mock