Refactored and cleaned code in tern manager

The purpose was to try to reduce the binding between brackets and tern.
tern manager needs to be unware brackets so that changes in tern and
changes in brackets are isolated