Adds mock + some refactoring