Implement tests, and fix broken features