Fix Phab:rP24185 style, add tests.
Patch by: @bb Small fixes by: @Stan
Reviewed by: @vladislavbelov
Differential Revision: https://code.wildfiregames.com/D3103