Fixed bug with embedded newlines and added supplementary test cases.

The originally test case had to be amended as it only happened to work
due to the presence of embedded spaces.
Fixed the output of empty strings vs a nil value, with test cases.
Merge pull request #3 from tychew/master

Embedded newlines and empty string fixes + tests