Corrected onEnd callback execution.
Updated unit tests.