Fix of issues #2851 and #3064 (1-3-stable branch)

https://github.com/dunric/spree-1/commit/7b9d0485ec5e2684038dc8ed295ae4e8ac81af04
https://github.com/dunric/spree-1/commit/17d3c773d3cee90ed63825be42f3135306fc7420