Flag register tests + bug fixing