cleaned up sys.c; moved test cases to separate file