Add missing tests, make tests less "interactive", minor fixes

Fixes a couple of bugs.
Simplified logic in a couple of places.
Added tests for <body> with border/margin/padding/boxSizing.
Refactored tests to make them less dependent from the actual interaction with the browser.