Refactored get_installed_tags_with_time

- Refactored AJAX tests
- Added test for `tags_for_session` AJAX endpoint
- Moved `get_installed_tags_with_time` into tag model
- Refactored `get_installed_tags_with_time` and `tags_for_session`
- Awesome database optimization: 66c0a21130dc8d5ab361ec6514695c21b68668ea (see [before/after](https://gist.github.com/dbrgn/427f5330cc08da1c3a4c))

See the commit messages for more detailed explanation.