Update registration algorithm.

* Resolve promise after successful worker script evaluation, before install.
* Fire installend event after install process.
Merge pull request #182 from nikhilm/register-algo-fix

Update registration algorithm.

Thanks @nikhilm!