Adding unit test and fixing NPE in ValidationFactory