Some fixes and eunit setup

This sucker will need a lot testing..