Refactor tests to reduce code duplication.
Merge pull request #33 from tuvistavie/refactor_tests

Refactor tests to reduce code duplication.