Add more test coverage

Fix infer_* logic for exiting after N iterations