Fix for minion_id detection regression + unit tests (2014.1 branch)

**This is against the 2014.1 branch**

2014.1.0 introduced a regression for edge cases where minion_id detection falls all the way back to parsing /etc/hosts, and there is an empty line in /etc/hosts.

This pull request includes the following:

1. The initial fix for that regression, originally contributed on 22 February.
2. A more pythonic fix, which replaces the original solution.
3. Unit tests I wrote to cover minion_id detection.