Fix bug in isInvalid and add test