Finished state machine for top level

Test vectors were also added.