Legacy signed cookie upgrader not handling hash values under 4 0

Noticed this the hard way while trying to upgrade my rails 4.0.8 app to use encrypted cookie store

cookie created with signed cookie store:

```ruby
[1] pry> cookies.signed[:name] = { value: { nr: 'a' } }
=> {:value=>"BAh7BjoHbnJJIgZhBjoGRVQ=--975531eb9ed8fd2527b9785dc58877b1116b6c2c",
 :path=>"/"}
```

after adding `secret_key_base` and restarting the app:

```ruby
[1] pry> cookies.signed[:name]
=> {:nr=>"a"}
[2] pry> cookies.signed[:name]
=> nil
```

cookie is being deleted after accessing it the first time. 
I noticed this is fixed in 4.1 https://github.com/rails/rails/commit/7a3ef9842b3cbfe6dbe14700086824d163ce4d51 but not in 4.0

Thanks