Added tests and a valid check method