Fixed the various things
Add some tests