Test corrections and minor refactor.