Added tests and code for ip function.