Fixed bug which caused an error without callback

An error was thrown when no callback was provided to dispatcher.dispatch.
Added testcase and refactored.