Small refactoring and added tests.
Also corrected midje dependency specification.