rtl_test: Refactoring, optimization and Windows port for PPM error measurement.