Merge pull request #410 from pedroigor/master

[PLINK-588] - Adding more tests.
[PLINK-588] - Code refactoring.