Few fixes and tests