Cleaned up flags.h
Added unit tests for delegates. Next up is tests for events and flags. Also fixed bugs found by unit tests.