Clean up and add more tests