Fixed concurrency bug.

The simOutput channel was never closed leading to deadlocks.
Also refactored some code.
Added additional regression test case.
Added minmax checks for data counts.