Created test for generate the error
Fixed the method 'preDispatch'