Add a test + small fixes