Refinement for the APIs.

test case is added as well.