Ensure is_valid() behaves properly.

Suggested by: dsnellgrove