Fix call to undefined function.
Fix 'LogicException: You are not allowed to use js in #attached'
Fix duplicated scoring key checking.
Default value of replacement map cache is an empty array.
Add test cases.
Fix coding standards errors and warnings.