Refactor and Add address more test scenarios