More refactoring for external execution integration, modularized testing