Refactor and test iota_scanner