Several small bug fixes to more correctly handle various edge cases and increase the number of passing tests from the Web Platform Tests (#137, #139, #141, #142, #143, #144, #145, #146 by @nolanlawson)