implement attachListeners/detachListeners
add unit test