Fixes the UI life-cycle environment test cases for UI update

Let's reduce waiting for ajax calls by adding it to this function itself.