Fix issue with previousElementSibling

Also adds a test to ensure no more silly bugs

Fixes #180