[AP-659] Javascript errors loading API Designer

It seems that scope.$root can be null in some cases (when nesting isolated and not isolated scopes, more info here: https://github.com/mgcrea/angular-strap/issues/774#issuecomment-44347448)
I also added some basic tests for the safeApply function (and of course a couple to ensure that the error is fixed).
1. We shouldn't and cannot reference internal tickets
2. Let's reword `shouldnt` as `should NOT` for better readability