error handling on validateFunc, tidied test cases

if non-null passed into validatFunc return error with 500 statusCode.
Tidied up test cases.