fixed all the Segmentation faults and test1 works with valgrind. test2 has some issues with valgrind but otherwise excuting correctly. Other test files need semaphores implmented