Adds new new_bug testcase, and fixes bug revealed by it