General refactoring of tests