added more conditions, fixed rules, added test for step 1b (first part)