clean and fileoutput for debugging
implemented timeout, optimised test