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

Hello

I can not test it on MacOS and WIndows but I hope that it works.