finish tests/functional.c but problems left