Fixed a related issue and better testing