test driver copied from main