Compact optomechanical switches and their applications in optical communication and testing systems