Added errors and tests