Refined some APIs and the codec test framework