Added tests, fixed bugs

Added tests for all of the stuff I committed earlier