added more error checking
expanded test file