fix($state): cleaning up and passing (more) tests