Optical testing and monitoring