More tests for splitLine

I have added more tests for splitLine helper. Fixed error that I found with those tests. Also refactored splitLine.