Fix parser bugs

Handle some situations with erb, rails-like associations and not-in-the-right-place variables.
See the added testcases for details.