Added tests for selectors
Fixed flatten method, now updates the working string via ref