moving code into more modular structure
added html5mode and refactored tests