Better tests, better logic