Ensure that loadingState element is being found

The initial test mock didn't take into consideration whether the button
state change was being applied to any elements or not. Now it checks
whether any elements are targeted and if it then applies the new state.