Update code and tests based on review feedback