improve API and tests