addded error fucntions to header and implemented in test.c