Refactoring and setting up testing automation