clean up
refactored further

refactored classes and tests to support pluggable ApplicationContext
for the engine