Small fixes and tests