ipcalc: refactoring and testing