code & unit test for spark context hang detection logic

Line 30-32: Please remove.