Add hazard analysis tests (and fix found bugs)