bug fixes and router tests

adding router tests and fixing some bugs