Begin test refactoring

[ci skip]