Metadata cleanup, configurable caching and additional tests

The title and the comments more or less speak for themselves, this patch cleans up some sloppiness and fixes a bug where the `$level` argument in `MetaBehavior::metadata()` has no effect, also it makes metadata caching configurable (as in makes it possible to choose the cache configuration and the key prefix to use) and adds some tests.