The additions I was talking about over fb

More tests and fixing a some other code to conform with the spec