Remove deprecated code and fix tests