Add tests for boundary conditions such as empty files (with and without headers) and apply fixes as needed