Major refactoring

This commit includes several changes to the code base.
There is everything from test location change to extraction of methods
to separate modules.

All feedback is appreciated. I hope I haven't overstepped my
boundaries.