More code improvements for engine testing.
part of #64.
Fix dynamic kernel for large tasks.