Unit tests in short. You need to check the coverage to make sure that when you make changes, you can re-run the tests and make sure that nothing is broken.
If you have continuous integration, then this will be displayed as / at registration. I would check earlier / often to make sure your changes are small and that you can easily track the causes of errors.
Headache restructures unit tests on an existing structure. You will probably have to rebuild some existing library to allow dependency injection and mocking . Unfortunately, just making these changes is not without its risks, and all this indicates that you can write tests as soon as possible (and develop code for the convenience of testing).