Fix optionsBeforeSubmit and tweak test

The optionsBeforeSubmit problem seems still exist in v0.5.10 master, and the unit test is't loaded in Grunt test. so I tried to fix them.
Please help me to review this patch, Thx.