Added tests for PostValidate method and a fix for a potential NPE