enhanced shutdown test and fixed implementation