Used $timeout.flush for testing functionality dependent on $timeout
Changing controller/service code as per John Papa's style guide