implements vairous APIs and add mock test.