fix JS typo
adding Js unit test

see #252
add check for logged out

fixes #256
code clean up