Added function to calculate test error.