fix a bug in WrapperFactory. add unit-tests for WrapperFactory.

Change-Id: Ia627dc7268cbfe02e183c3b44b2e690352cea00a