move struct def into internal.h
add unit tests on failure.