Initial refactoring of tests