adding test() function and encapsulating operatorControl in while loop