refactor arbitrator and add tests