Fixed races in calculation of S file and added test for lcs I/O