Clean up & add tests