modify APIs to support temp-files free testing