[enh] added O2 optimization for tests