more cleanup
use realloc
adjusted tests after Franks changes