Using factory to test API