better handle navbar.
better handle authentication within template.
add related unit tests.
made some cleanup.