Quality of code determines the quality of the test.

An unclean code will lead to an unclean test.

Hence, the tests will be as hard to understand and modify as the code.

If one decides to improve code quality, then all of the tests to be refactored too.

Overall the workload will be about thrice more work than it needs to be.

A better alternative is to write code, clean it, and write tests.