Cleaning up and fixing tests