Convert to DOM Promises polyfill

* Migrated Deferred and when to polyfill
* Add unit tests for Deferred and when