Added Module level methods as well as dynamic methods for easy access to states and events.
Also, some testing codes are added using RSpec.