Fix medium subtracting and add test for it