Better tests, cleanup