Tail additional tests and updated loop

Added tests for larger files
Fixes for various bugs highlighted by tests.