0.4 Testing and bugfix

The target was to achieve as high a coverage as possible with testing. The coverage reports show almost 100% coverage with the only remaining lines being the untestable ones due to JS platform differences.

This also fixes multiple edge-case bugs from 0.3 line.