refactoring handlers, improved tests
tweaks