Fixing and adding tests