Refactoring tests and adding a gradle build