added test code for C API