add test end detection