A few fixes and and add a test