Add unit test to check end_of_round, fix bugs in in function end_of_round