Added Midje tests. Some functions tweaked.