added calibration function and test, fixed some tests