Removed duplicated code and fix for failing test
Merge pull request #314 from AndreiH/removed_duplicate

Removed duplicated code and fix for failing test