added test for failing prepre
errmsg() support
C++ refactoring