Applied @rykov's better code

and added some specs pointing out the STI edge cases addressed by that