Refactored valgrind validations check to work like checkstyle validations for java

In previous implementation users got confisung results of tests passing
and valgrind errors.