A bit of restructuring
New unit tests