Token: added more checks on input parameter to give better reason than NPE