create table function and tests