Fixed it so that the unit tests works. Also cleaned up a little bit.