minor refactoring & error testing