Make changes for review feedback and expose some more apis for unit tests.