Add implementation code and enhance test.