fix priority, add assert, add unit test