Add methods that Python provides for dicts and lists.

This is useful for people that are porting code. Many things that depend on simple methods (which don't exist in JS or don't have a 1:1 correspondence) would otherwise break while porting server-side templates to the client.

This adds the necessary methods and the corresponding tests.