Changed the status determination logic and adding integration test