API function validate() supports returning of deferred promise object

I added this in order to support async validation (custom modal popup / validation depending on AJAX / ...)
When returning direct value - it resolves immediately so no change here.

I wrote additional tests for added functionality. All test passed, but 2 - those didn't pass even before any change happened.