ip_record tests

Big cleanup of `ip_record.js` while writing unit tests for it.