Updating to new code and adding tests