Fix #797 and Add a test suite for the IP validator.

1. Fix #797 
2. Add a test suite for the IP validator.