add test mode to native library loader and fix stream handling