Make impl more generic and expand tests.