fixed bug on empty doc in train and test; added arg switch for test file