Tests and fixes

Added tests and stuff
Fixed it too