The only way I know is:
- write tests
- refactor
- run the tests
- fix what's broken
- write tests for the new feature
- introduce new feature
- run the tests
- fix what's broken
You may live through it this way.
NOTE: there are some times where it's really hard to unit test spaghetti code: 3Klines methods which generate HTML, DAOs entangled with business logic, strongly coupled classes... in this cases a good IDE with automatic refactoring (capable of extracting methods, to begin with) and some test tools like Selenium may come in really handy.