API cleanups and better tests