Python fixes2

fixes and tests for #1718, #2375, #2587, #2613