Notifications: performance and casting of notification setting values

This makes sure we don't encounter type mismatch given notifications settings are stored as metadata.
Improves performance by constraining elgg_get_metadata(), and uses create_metadata to avoid getting the entity.
Adds regression tests.