Asymptotically optimal tests and optimal designs for testing the mean in regression models with applications to change-point problems